<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  left: 0;
  top: 0;
  .top_config_title {
    width: 100%;
    height: 60px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    padding: 0 0 20px 20px;
    box-sizing: border-box;
  }
  .model_con {
    width: 900px;
    // height: 600px;
    background: #fff;
    padding: 20px;
    box-sizing: border-box;
  }
  .dialog_footer {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    padding: 20px;
    box-sizing: border-box;
  }
}
</style>
<template>
  <div>
    <el-dialog
      title="Cron表达式"
      :visible.sync="dispatchVis"
      append-to-body
      destroy-on-close
      :close-on-click-modal="false"
      :show-close="false"
      class="scrollbar"
    >
      <crontab
        @hide="cancelCrossBox"
        @fill="crontabFill"
        :expression="expression"
      ></crontab>
    </el-dialog>
  </div>
</template>

<script>
import {updateJobDispatch} from "@/api/base/jobDispatch"
import Crontab from "@/components/Crontab";
var jobId = null;
export default {
  name: "coreManaDialog",
  data() {
    return {
      // 表单参数
      form: {},
      // 表单校验
      expression: "", // 传入的表达式
    };
  },
  dicts: ["sys_job_group", "sys_job_status"],
  components: {
    Crontab,
  },
  watch: {
    dispatchVis: {
      handler(val) {
        if (val) {
        }
      },
    },
    ediExpressionObj: {
      handler(val) {
        this.expression = val.cronExpression;
        jobId = val.jobId;
      },
      deep: true,
    },
  },
  props: {
    dispatchVis: {
      type: Boolean,
      default: false,
    },
    ediExpressionObj: {
      type: Object,
      default: () => {
        return {};
      },
    },
    name: {
      type: String,
      default: "",
    },
  },
  // 销毁监听，防止内存泄露
  beforeDestroy() {},
  methods: {
    /** 确定后回传值 */
    crontabFill(value) {
      this.form.cronExpression = value;
      if (this.name === "thresholdValue") {
        //阈值管理中的函数
        this.$parent.configDraFun(value);
      } else {
        let param = {
          //设备中配置的定时调度
          jobId,
          cronExpression: value,
        };
        console.log("param",param)
        updateJobDispatch(param).then((res) => {
          this.$parent.configDraFun();
        });
      }
    },
    cancelCrossBox() {
      this.$parent.cancelCrossBox();
    },
  },
};
</script>
